#! /usr/bin/env python
# -*- coding: utf-8 -*-
# __author__ = "Q1mi"
# Date: 2018/10/25
import pymssql

def Sql(sql_pre,obtain=True):
    '''
    :param sql_pre: 数据库语句
    :param obtain: 查询数据库的内容返回
    :return: 对数据库进行增删改查
    '''
    server = "119.29.146.108"
    user = "sa"
    password = "S3686-e342qq-3686e342"

    connect = pymssql.connect(server, user, password, "istrong_data_collection", charset="utf8")  # 获取连接
    cursor = connect.cursor()  # 获取光标

    cursor.execute(sql_pre)
    if obtain:
        number = cursor.fetchall()
        connect.commit()
        connect.close()
        return number
    else:
        connect.commit()
        connect.close()

